package com.knife.bbs.object;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.knife.util.CommUtil;

/**
 * BBS帖子
 */
public class BBSDoc{
	//Fields    
	private static final SimpleDateFormat df=new SimpleDateFormat("yyyyMMdd");
    private String cid;
    private String dirsn;
    private String dirpath;
    private String parentid;
    private String title;
    private String content;
    private String intro;
    private String files;
    private String imgs;
    private Integer readtimes;  
    private String tagpic;
    private Integer votescore;
    private Integer score;
    private String vrtype;
    private String vrvalue;    
    private String inputuser;
    private Date inputtime;
    private Date modifytime;
    private String ip;
    private String clientinfo;
    private Integer good;
    private Integer bad;
    private String source;
    private Integer topmessage;
    private Integer elitemessage;
    private Integer status;    
    private Integer hasvote;
    private String href;
    
    private String lastupdateuser;
    private Date lastupdatetime;
    private Integer replynum;
    private String showpic;
    
    public static final String[][] vRTypeTitle={{"","公开"},{"user","会员可见"},{"score","积分限制"},{"reply","回复可见"},{"member","VIP可见"},{"admin","管理员"}};
    
    public String htmlUrl()
	{
		String ret="/bbsdoc.do?parameter=show&cid="+this.getCid();
		/*
		if(this.vrtype==null || "".equals(this.vrtype)){
			if(this.inputtime!=null)ret="/bbs/"+df.format(this.inputtime)+"/"+this.cid+".htm";
		}
		*/
		return ret;
	}
	
    public String staticHtmlUrl()
	{
		String ret="";		
		if(this.inputtime!=null){
			ret="/bbs/"+df.format(this.inputtime)+"/"+this.cid+".htm";
		}
		return ret;
	}
    
	public boolean canPublish()
	{
		if(this.vrtype!=null&&(!"".equals(this.vrtype)))return false;
		else return true;
	}
	
    public Integer getHasvote() {
		return hasvote;
	}
    
	public void setHasvote(Integer hasvote) {
		this.hasvote = hasvote;
	}
	
	//Constructors
    public BBSDoc()
    {
    }
    
    //类的方法
	public boolean isTop()
	{
		return (topmessage!=null && topmessage.intValue()==1);
	}
	
	public boolean isElite()
	{
		return (elitemessage!=null && elitemessage.intValue()==1);
	}
	
	public boolean isHot()
	{
		return (readtimes!=null && readtimes.intValue()>500);
	}
	
	public boolean isLock()
	{
		return false;
	}
	
	public boolean isReply()
	{
		return (this.parentid!=null) && !"".equals(this.parentid);
	}
	
	public String showVRTypesSelect(){
	     return CommUtil.getSelectOptions(vRTypeTitle,vrtype!=null?vrtype:"");
	}
	
		public String showVRTypeTitle()
		{
			String ret="";
			if(vrtype==null || vrtype.equals(""))ret= "无任何限制!";
			else if(vrtype.equals("user"))ret= "该主题的内容只有登录后才能显示!";
			else if(vrtype.equals("score"))ret="该主题的内容只有积分达到"+this.vrvalue+"的用户才能阅读!";
			else if(vrtype.equals("reply"))ret="该主题的内容只有回复后才能阅读!";
			else if(vrtype.equals("member"))ret="该主题只有会员才能阅读!";
			else if(vrtype.equals("admin"))ret="该主题只有管理员才能阅读!";
			return ret;		
		}
	
	//Property accessors
	public Integer getBad() {
		return bad;
	}
	
	public void setBad(Integer bad) {
		this.bad = bad;
	}
	
	public String getCid() {
		return cid;
	}
	
	public void setCid(String cid) {
		this.cid = cid;
	}
	
	public String getClientinfo() {
		return clientinfo;
	}
	public void setClientinfo(String clientInfo) {
		this.clientinfo = clientInfo;
	}
	
	public String getContent() {
		return content;
	}
	
	public void setContent(String content) {
		this.content = content;
	}
	
	public String getDirsn() {
		return dirsn;
	}
	
	public void setDirsn(String dirSn) {
		this.dirsn = dirSn;
	}
	
	public String getFiles() {
		return files;
	}
	
	public void setFiles(String files) {
		this.files = files;
	}
	
	public Integer getGood() {
		return good;
	}
	
	public void setGood(Integer good) {
		this.good = good;
	}
	
	public String getImgs() {
		return imgs;
	}
	
	public void setImgs(String imgs) {
		this.imgs = imgs;
	}
	
	public Date getInputtime() {
		return inputtime;
	}
	
	public void setInputtime(Date inputTime) {
		this.inputtime = inputTime;
	}
	
	public String getInputuser() {
		return inputuser;
	}
	
	public void setInputuser(String inputUser) {
		this.inputuser = inputUser;
	}
	
	public String getIntro() {
		return intro;
	}
	
	public void setIntro(String intro) {
		this.intro = intro;
	}
	
	public String getIp() {
		return ip;
	}
	
	public void setIp(String ip) {
		this.ip = ip;
	}
	
	public Date getModifytime() {
		return modifytime;
	}
	
	public void setModifytime(Date modifyTime) {
		this.modifytime = modifyTime;
	}
	
	public String getParentid() {
		return parentid;
	}
	
	public void setParentid(String parentId) {
		this.parentid = parentId;
	}
	
	public Integer getReadtimes() {
		return readtimes;
	}
	
	public void setReadtimes(Integer readTimes) {
		this.readtimes = readTimes;
	}
	
	public Integer getScore() {
		return score;
	}
	
	public void setScore(Integer score) {
		this.score = score;
	}
	
	public String getSource() {
		return source;
	}
	
	public void setSource(String source) {
		this.source = source;
	}
	
	public Integer getStatus() {
		return status;
	}
	
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public String getTagpic() {
		return tagpic;
	}
	
	public void setTagpic(String tagPic) {
		this.tagpic = tagPic;
	}
	
	public String getTitle() {
		return title;
	}
	
	public void setTitle(String title) {
		this.title = title;
	}
	
	public Integer getVotescore() {
		return votescore;
	}
	
	public void setVotescore(Integer voteScore) {
		this.votescore = voteScore;
	}
	
	public String getVrtype() {
		return vrtype;
	}
	
	public void setVrtype(String type) {
		vrtype = type;
	}
	
	public String getVrvalue() {
		return vrvalue;
	}
	
	public void setVrvalue(String value) {
		vrvalue = value;
	}
	
	public Integer getElitemessage() {
		return elitemessage;
	}
	
	public void setElitemessage(Integer eliteMessage) {
		this.elitemessage = eliteMessage;
	}
	
	public Integer getTopmessage() {
		return topmessage;
	}
	
	public void setTopmessage(Integer topMessage) {
		this.topmessage = topMessage;
	}   
	
	public Date getLastupdatetime() {
		return lastupdatetime;
	}
	
	public void setLastupdatetime(Date lastUpdateTime) {
		this.lastupdatetime = lastUpdateTime;
	}
	
	public String getLastupdateuser() {
		return lastupdateuser;
	}
	
	public void setLastupdateuser(String lastUpdateUser) {
		this.lastupdateuser = lastUpdateUser;
	}
	
	public Integer getReplynum() {
		return replynum;
	}
	
	public void setReplynum(Integer replyNum) {
		this.replynum = replyNum;
	}
	
	public String getDirpath() {
		return dirpath;
	}
	
	public void setDirpath(String dirPath) {
		this.dirpath = dirPath;
	}
	
	public String getShowpic() {
		return showpic;
	}

	public void setShowpic(String showpic) {
		this.showpic = showpic;
	}

	public String getHref() {
		if(this.href!=null){
			return href;
		}else{
			return "/bbsdoc.do?parameter=show&cid="+this.getCid();
		}
	}

	public void setHref(String href) {
		this.href = href;
	}

	public String toString() {
		// TODO Auto-generated method stub
		String ret="BBSDoc:     cid"+cid+"   dirsn"+dirsn+"   parentid"+parentid+"   title"+title+"   hasvote"+hasvote+"   status"+status;
		return ret;
	}
	
	public BBSDoc(com.knife.bbs.domain.BBSDoc doc){
		this.bad=doc.getBad();
		this.cid=doc.getCid();
		this.clientinfo=doc.getClientinfo();
		this.content=doc.getContent();
		this.dirpath=doc.getDirpath();
		this.dirsn=doc.getDirsn();
		this.elitemessage=doc.getElitemessage();
		this.files=doc.getFiles();
		this.good=doc.getGood();
		this.hasvote=doc.getHasvote();
		this.imgs=doc.getImgs();
		this.inputtime=doc.getInputtime();
		this.inputuser=doc.getInputuser();
		this.intro=doc.getIntro();
		this.ip=doc.getIp();
		this.lastupdatetime=doc.getLastupdatetime();
		this.lastupdateuser=doc.getLastupdateuser();
		this.modifytime=doc.getModifytime();
		this.parentid=doc.getParentid();
		this.readtimes=doc.getReadtimes();
		this.replynum=doc.getReplynum();
		this.score=doc.getScore();
		this.source=doc.getSource();
		this.status=doc.getStatus();
		this.tagpic=doc.getTagpic();
		this.title=doc.getTitle();
		this.topmessage=doc.getTopmessage();
		this.votescore=doc.getVotescore();
		this.vrtype=doc.getVrtype();
		this.vrvalue=doc.getVrvalue();
		this.href="/bbsdoc.do?parameter=show&cid="+this.getCid();
		if(this.isTop()){
			this.showpic="/images/bbs/top.gif";
		}else if(this.isElite()){
			this.showpic="/images/bbs/jinghua.gif";
		}else if(this.isHot()){
			this.showpic="/images/bbs/remen.gif";
		}else{
			this.showpic="/images/bbs/folder.gif";
		}
	}
}
